*1. Preliminary Commands

log using "X:\Dissertation\FPV Data Cleaning Log CAO 2020xxxx.smcl"

import excel "X:\Dissertation\Dissertation Dataset.xlsx", sheet("Dataset (2)") firstrow case(lower)

set more off

*2. Item Identification Number

rename itemidentificationnumber iin

*3. Publication

tab publication
gen publication2 = .
replace publication2 = 1 if publication == "Dabiq"
replace publication2 = 2 if publication == "Inspire"
label variable publication2 "Publication (2)"
label define publication2 1 "Dabiq" 2 "Inspire"
label values publication2 publication2
tab publication2, m

*4. Defensive framing

tab aggression, m
gen aggression2 = 0
replace aggression2 = 1 if aggression == "Yes"
label variable aggression2 "Aggression (2)"
label define aggression2 0 "No" 1 "Yes"
label values aggression2 aggression2
tab aggression2, m

tab destruction, m
gen destruction2 = 0
replace destruction2 = 1 if destruction == "Yes"
label variable destruction2 "Destruction (2)"
label define destruction2 0 "No" 1 "Yes"
label values destruction2 destruction2
tab destruction2, m

tab violence, m
gen violence2 = 1
replace violence2 = 0 if violence == "."
label variable violence2 "Violence (2)"
label define violence2 0 "No" 1 "Yes"
label values violence2 violence2
tab violence2, m

*5. Moralistic framing

tab sexualimmorality, m
gen seximm = 1
replace seximm = 0 if sexualimmorality == "."
label variable seximm "Sexual Immorality"
label define seximm 0 "No" 1 "Yes"
label values seximm seximm
tab seximm, m

tab intoxicants, m
gen intox = 1
replace intox = 0 if intoxicants == "."
label variable intox "Intoxicants"
label define intox 0 "No" 1 "Yes"
label values intox intox
tab intox, m

gen sii = 0
replace sii = 1 if seximm == 1
replace sii = 1 if intox == 1
label variable sii "Sexual Immorality & Intoxicants"
label define sii 0 "No" 1 "Yes"
label values sii sii
tab sii, m

*6. Legalistic framing

tab sharia, m
gen sharia2 = 0
replace sharia2 = 1 if sharia == "Yes"
label variable sharia2 "Sharia (2)"
label define sharia2 0 "No" 1 "Yes"
label values sharia2 sharia2
tab sharia2, m

*7. Imperialistic framing

tab worlddomination, m
gen worlddom = 0
replace worlddom = 1 if worlddomination == "Yes"
label variable worlddom "World Domination (2)"
label define worlddom 0 "No" 1 "Yes"
label values worlddom worlddom
tab worlddom, m

*8. Apocalyptic framing

tab apocalypticterminology, m
gen apocterm = 1
replace apocterm = 0 if apocalypticterminology == "."
label variable apocterm "Apocalyptic Terminology (2)"
label define apocterm 0 "No" 1 "Yes"
label values apocterm apocterm
tab apocterm, m

*9. Countries

split countries, p(";")

gen ctafghanistan = 0
gen ctalgeria = 0
gen ctaustralia = 0
gen ctbahrain = 0
gen ctbelgium = 0
gen ctburundi = 0
gen ctcameroon = 0
gen ctcanada = 0
gen ctchad = 0
gen ctchina = 0
gen ctdenmark = 0
gen ctegypt = 0
gen cteuro = 0
gen ctfrance = 0
gen ctgermany = 0
gen ctindia = 0
gen ctiran = 0
gen ctiraq = 0
gen ctisrael = 0
gen ctjordan = 0
gen ctkuwait = 0
gen ctlebanon = 0
gen ctlibya = 0
gen ctmorocco = 0
gen ctnetherlands = 0
gen ctniger = 0
gen ctnigeria = 0
gen ctnato = 0
gen ctoman = 0
gen ctpakistan = 0
gen ctpalestine = 0
gen ctqatar = 0
gen ctrussia = 0
gen ctsaudi = 0
gen ctsyria = 0
gen cttunisia = 0
gen ctturkey = 0
gen ctuae = 0
gen ctuk = 0
gen ctun = 0
gen ctusa = 0
gen ctyemen = 0
gen ctother = 0

label variable ctafghanistan "Afghanistan identified as enemy"
label variable ctalgeria "Algeria identified as enemy"
label variable ctaustralia "Australia identified as enemy"
label variable ctbahrain "Bahhrain identified as enemy"
label variable ctbelgium "Belgium identified as enemy"
label variable ctburundi "Burundi identified as enemy"
label variable ctcameroon "Cameroon identified as enemy"
label variable ctcanada "Canada identified as enemy"
label variable ctchad "Chad identified as enemy"
label variable ctchina "China identified as enemy"
label variable ctdenmark "Denmark identified as enemy"
label variable ctegypt "Egypt identified as enemy"
label variable cteuro "European Union identified as enemy"
label variable ctfrance "France identified as enemy"
label variable ctgermany "Germany identified as enemy"
label variable ctindia "India identified as enemy"
label variable ctiran "Iran identified as enemy"
label variable ctiraq "Iraq identified as enemy"
label variable ctisrael "Israel identified as enemy"
label variable ctjordan "Jordan identified as enemy"
label variable ctkuwait "Kuwait identified as enemy"
label variable ctlebanon "Lebanon identified as enemy"
label variable ctlibya "Libya identified as enemy"
label variable ctmorocco "Morocco identified as enemy"
label variable ctnetherlands "Netherlands identified as enemy"
label variable ctniger "Niger identified as enemy"
label variable ctnigeria "Nigeria identified as enemy"
label variable ctnato "North Atlantic Treaty Organization identified as enemy"
label variable ctoman "Oman identified as enemy"
label variable ctpakistan "Pakistan identified as enemy"
label variable ctpalestine "Palestinian Authority identified as enemy"
label variable ctqatar "Qatar identified as enemy"
label variable ctrussia "Russia identified as enemy"
label variable ctsaudi "Saudi Arabia identified as enemy"
label variable ctsyria "Syrian Arab Republic identified as enemy"
label variable cttunisia "Tunisia identified as enemy"
label variable ctturkey "Turkey identified as enemy"
label variable ctuae "United Arab Emirates identified as enemy"
label variable ctuk "United Kingdom"
label variable ctun "United Nations identified as enemy"
label variable ctusa "United States identified as enemy"
label variable ctyemen "Yemen identified as enemy"
label variable ctother "Other nation-states identified as enemy"

local countriesvars "countries1 countries2 countries3 countries4 countries5 countries6 countries7 countries8 countries9 countries10 countries11 countries12 countries13 countries14 countries15 countries16 countries17 countries18 countries19 countries20 countries21 countries22 countries23 countries24 countries25 countries26 countries27 countries28 countries29 countries30 countries31 countries32 countries33 countries34 countries35 countries36 countries37 countries38 countries39 countries40 countries41 countries42 countries43 countries44 countries45 countries46 countries47 countries48 countries49 countries50 countries51 countries52 countries53 countries54 countries55 countries56 countries57 countries58 countries59 countries60 countries61 countries62 countries63 countries64 countries65 countries66 countries67 countries68 countries69 countries70 countries71 countries72 countries73 countries74 countries75 countries76 countries77 countries78"
foreach varname of local countriesvars {
replace ctafghanistan = 1 if `varname' == "Afghanistan"
replace ctalgeria = 1 if `varname' == "Algeria"
replace ctaustralia = 1 if `varname' == "Australia"
replace ctbahrain = 1 if `varname' == "Bahrain"
replace ctbelgium = 1 if `varname' == "Belgium"
replace ctburundi = 1 if `varname' == "Burundi"
replace ctcameroon = 1 if `varname' == "Cameroon"
replace ctcanada = 1 if `varname' == "Canada"
replace ctchad = 1 if `varname' == "Chad"
replace ctchina = 1 if `varname' == "China"
replace ctdenmark = 1 if `varname' == "Denmark"
replace ctegypt = 1 if `varname' == "Egypt"
replace cteuro = 1 if `varname' == "European Union (EU)"
replace ctfrance = 1 if `varname' == "France"
replace ctgermany = 1 if `varname' == "Germany"
replace ctindia = 1 if `varname' == "India"
replace ctiran = 1 if `varname' == `"Iran (“Persia,” “Tehran”)"'
replace ctiraq = 1 if `varname' == "Iraq"
replace ctisrael = 1 if `varname' == "Israel"
replace ctjordan = 1 if `varname' == "Jordan"
replace ctkuwait = 1 if `varname' == "Kuwait"
replace ctlebanon = 1 if `varname' == "Lebanon"
replace ctlibya = 1 if `varname' == "Libya"
replace ctmorocco = 1 if `varname' == "Morocco"
replace ctnetherlands = 1 if `varname' == "Netherlands"
replace ctniger = 1 if `varname' == "Niger"
replace ctnigeria = 1 if `varname' == "Nigeria"
replace ctnato = 1 if `varname' == "North Atlantic Treaty Organization (NATO)"
replace ctoman = 1 if `varname' == "Oman"
replace ctpakistan = 1 if `varname' == "Pakistan"
replace ctpalestine = 1 if `varname' == "Palestinian Authority"
replace ctqatar = 1 if `varname' == "Qatar"
replace ctrussia = 1 if `varname' == "Russia"
replace ctsaudi = 1 if `varname' == "Saudi Arabia"
replace ctsyria = 1 if `varname' == "Syrian Arab Republic (Assad regime)"
replace cttunisia = 1 if `varname' == "Tunisia"
replace ctturkey = 1 if `varname' == "Turkey"
replace ctuae = 1 if `varname' == "United Arab Emirates"
replace ctuk = 1 if `varname' == "United Kingdom"
replace ctun = 1 if `varname' == "United Nations (UN)"
replace ctusa = 1 if `varname' == `"United States (“America,” “Washington, DC”)"'
replace ctyemen = 1 if `varname' == "Yemen"
replace ctother = 1 if `varname' == "African Union"
replace ctother = 1 if `varname' == "Albania"
replace ctother = 1 if `varname' == "Arab League"
replace ctother = 1 if `varname' == "Arab regimes"
replace ctother = 1 if `varname' == "Armenia"
replace ctother = 1 if `varname' == "Austria"
replace ctother = 1 if `varname' == "Azerbaijan"
replace ctother = 1 if `varname' == "Bangladesh"
replace ctother = 1 if `varname' == "Benin"
replace ctother = 1 if `varname' == "Bosnia and Herzegovina"
replace ctother = 1 if `varname' == "Bulgaria"
replace ctother = 1 if `varname' == "Burma"
replace ctother = 1 if `varname' == "Coalition of the Willing"
replace ctother = 1 if `varname' == "Croatia"
replace ctother = 1 if `varname' == "Cyprus"
replace ctother = 1 if `varname' == "Czech Republic"
replace ctother = 1 if `varname' == "Estonia"
replace ctother = 1 if `varname' == "Europe"
replace ctother = 1 if `varname' == "Finland"
replace ctother = 1 if `varname' == "Georgia"
replace ctother = 1 if `varname' == "Greece"
replace ctother = 1 if `varname' == "Gulf Cooperation Council"
replace ctother = 1 if `varname' == "Hungary"
replace ctother = 1 if `varname' == "Iceland"
replace ctother = 1 if `varname' == "Indonesia"
replace ctother = 1 if `varname' == "Ireland"
replace ctother = 1 if `varname' == "Italy"
replace ctother = 1 if `varname' == "Japan"
replace ctother = 1 if `varname' == "Kenya"
replace ctother = 1 if `varname' == "Kosovo"
replace ctother = 1 if `varname' == "Kyrgyzstan"
replace ctother = 1 if `varname' == "Latvia"
replace ctother = 1 if `varname' == "Lithuania"
replace ctother = 1 if `varname' == "Luxembourg"
replace ctother = 1 if `varname' == "Macedonia"
replace ctother = 1 if `varname' == "Malaysia"
replace ctother = 1 if `varname' == "Mali"
replace ctother = 1 if `varname' == "Moldova"
replace ctother = 1 if `varname' == "Mongolia"
replace ctother = 1 if `varname' == "Montenegro"
replace ctother = 1 if `varname' == "Myanmar"
replace ctother = 1 if `varname' == "New Zealand"
replace ctother = 1 if `varname' == "Norway"
replace ctother = 1 if `varname' == "Organization of Islamic Cooperation"
replace ctother = 1 if `varname' == "Panama"
replace ctother = 1 if `varname' == "Philippines"
replace ctother = 1 if `varname' == "Poland"
replace ctother = 1 if `varname' == "Portugal"
replace ctother = 1 if `varname' == "Republic of Korea (South Korea)"
replace ctother = 1 if `varname' == "Romania"
replace ctother = 1 if `varname' == "Senegal"
replace ctother = 1 if `varname' == "Serbia"
replace ctother = 1 if `varname' == "Singapore"
replace ctother = 1 if `varname' == "Slovakia"
replace ctother = 1 if `varname' == "Slovenia"
replace ctother = 1 if `varname' == "Somalia"
replace ctother = 1 if `varname' == "Spain"
replace ctother = 1 if `varname' == "Sudan"
replace ctother = 1 if `varname' == "Sweden"
replace ctother = 1 if `varname' == "Switzerland"
replace ctother = 1 if `varname' == "Taiwan"
replace ctother = 1 if `varname' == "Tajikistan"
replace ctother = 1 if `varname' == "The West"
replace ctother = 1 if `varname' == "Ukraine"
replace ctother = 1 if `varname' == "the West"
}

gen ctislamic = 0
replace ctislamic = 1 if ctafghanistan == 1
replace ctislamic = 1 if ctalgeria == 1
replace ctislamic = 1 if ctbahrain == 1
replace ctislamic = 1 if ctchad == 1
replace ctislamic = 1 if ctegypt == 1
replace ctislamic = 1 if ctiran == 1
replace ctislamic = 1 if ctiraq == 1
replace ctislamic = 1 if ctjordan == 1
replace ctislamic = 1 if ctkuwait == 1
replace ctislamic = 1 if ctlebanon == 1
replace ctislamic = 1 if ctlibya == 1
replace ctislamic = 1 if ctmorocco == 1
replace ctislamic = 1 if ctniger == 1
replace ctislamic = 1 if ctoman == 1
replace ctislamic = 1 if ctpakistan == 1
replace ctislamic = 1 if ctpalestine == 1
replace ctislamic = 1 if ctqatar == 1
replace ctislamic = 1 if ctsaudi == 1
replace ctislamic = 1 if ctsyria == 1
replace ctislamic = 1 if cttunisia == 1
replace ctislamic = 1 if ctturkey == 1
replace ctislamic = 1 if ctuae == 1
replace ctislamic = 1 if ctyemen == 1
label variable ctislamic "Islamic countries identified as enemy"
label define ctislamic 0 "No" 1 "Yes"
label values ctislamic ctislamic
tab ctislamic, m

gen ctwestern = 0
replace ctwestern = 1 if ctaustralia == 1
replace ctwestern = 1 if ctbelgium == 1
replace ctwestern = 1 if ctcanada == 1
replace ctwestern = 1 if ctdenmark == 1
replace ctwestern = 1 if ctfrance == 1
replace ctwestern = 1 if ctgermany == 1
replace ctwestern = 1 if ctnetherlands == 1
replace ctwestern = 1 if ctnato == 1
replace ctwestern = 1 if ctuk == 1
replace ctwestern = 1 if ctusa == 1
label variable ctwestern "Western countries identified as enemy"
label define ctwestern 0 "No" 1 "Yes"
label values ctwestern ctwestern
tab ctwestern, m

tab ctusa, m

drop countries1 countries2 countries3 countries4 countries5 countries6
drop countries7 countries8 countries9 countries10 countries11 countries12
drop countries13 countries14 countries15 countries16 countries17 countries18
drop countries19 countries20 countries21 countries22 countries23 countries24
drop countries25 countries26 countries27 countries28 countries29 countries30
drop countries31 countries32 countries33 countries34 countries35 countries36
drop countries37 countries38 countries39 countries40 countries41 countries42
drop countries43 countries44 countries45 countries46 countries47 countries48
drop countries49 countries50 countries51 countries52 countries53 countries54
drop countries55 countries56 countries57 countries58 countries59 countries60
drop countries61 countries62 countries63 countries64 countries65 countries66
drop countries67 countries68 countries69 countries70 countries71 countries72
drop countries73 countries74 countries75 countries76 countries77 countries78
drop countries79 countries80 countries81 countries82 countries83 countries84
drop countries85 countries86 countries87 countries88 countries89 countries90

*10. Religions

split religions, p(";")

gen rgahmadis = 0
gen rgalawites = 0
gen rgatheists = 0
gen rgbahais = 0
gen rgbuddhists = 0
gen rgchristians = 0
gen rgdruze = 0
gen rgorthodox = 0
gen rghindus = 0
gen rgjews = 0
gen rgnonmuslims = 0
gen rgpolytheists = 0
gen rgprotestants = 0
gen rgcatholics = 0
gen rgshias = 0
gen rgsufis = 0
gen rgsunnis = 0
gen rgyazidis = 0
gen rgzoroastrians = 0
gen rgother = 0

label variable rgahmadis "Ahmadis identified as enemy"
label variable rgalawites "Alawites identified as enemy"
label variable rgatheists "Atheists identified as enemy"
label variable rgbahais "Bahais identified as enemy"
label variable rgbuddhists "Buddhists identified as enemy"
label variable rgchristians "Christians identified as enemy"
label variable rgdruze "Druze identified as enemy"
label variable rgorthodox "Eastern Orthodox Christians identified as enemy"
label variable rghindus "Hindus identified as enemy"
label variable rgjews "Jews/Judaism identified as enemy"
label variable rgnonmuslims "Non-Muslims identified as enemy"
label variable rgpolytheists "Polytheists identified as enemy"
label variable rgprotestants "Protestants identified as enemy"
label variable rgcatholics "Catholics identified as enemy"
label variable rgshias "Shias identified as enemy"
label variable rgsufis "Sufis identified as enemy"
label variable rgsunnis "Sunnis identified as enemy"
label variable rgyazidis "Yazidis identified as enemy"
label variable rgzoroastrians "Zoroastrians identified as enemy"
label variable rgother "Other religions identified as enemy"

local religionsvars "religions1 religions2 religions3 religions4 religions5 religions6 religions7 religions8 religions9 religions10 religions11 religions12 religions13 religions14 religions15"
foreach varname of local religionsvars {
replace rgahmadis = 1 if `varname' == "Ahmadi Muslims"
replace rgalawites = 1 if `varname' == "Alawites (“Nusayris,” subset of Shias, check for variant spellings)"
replace rgatheists = 1 if `varname' == "Atheists"
replace rgbahais = 1 if `varname' == "Bahais"
replace rgbuddhists = 1 if `varname' == "Buddhists"
replace rgchristians = 1 if `varname' == "Christians (“Cross worshippers”)"
replace rgdruze = 1 if `varname' == "Druze"
replace rgorthodox = 1 if `varname' == "Eastern Orthodox Christians"
replace rghindus = 1 if `varname' == "Hindus"
replace rgjews = 1 if `varname' == "Jews/Judaism"
replace rgnonmuslims = 1 if `varname' == "Non-Muslims"
replace rgpolytheists = 1 if `varname' == "Polytheists"
replace rgprotestants = 1 if `varname' == "Protestant Christians"
replace rgcatholics = 1 if `varname' == "Roman Catholic Christians"
replace rgshias = 1 if `varname' == "Shia Muslims (various pejorative terms)"
replace rgsufis = 1 if `varname' == "Sufi Muslims (“Safawis,” check for variant spellings)"
replace rgsunnis = 1 if `varname' == "Sunni Muslims"
replace rgyazidis = 1 if `varname' == "Yazidis"
replace rgzoroastrians = 1 if `varname' == "Zoroastrians"
replace rgother = 1 if `varname' == "Agnostics"
replace rgother = 1 if `varname' == "Ahl-i Hadith"
replace rgother = 1 if `varname' == "Conservative Jews"
replace rgother = 1 if `varname' == "Coptic Christians"
replace rgother = 1 if `varname' == "Deobandi Muslims"
replace rgother = 1 if `varname' == "Isma'iliyyah"
replace rgother = 1 if `varname' == "Ismaili Muslims"
replace rgother = 1 if `varname' == "Modernist Muslims"
replace rgother = 1 if `varname' == "Naqshbandi-Haqqani Sufi Order of America"
replace rgother = 1 if `varname' == "Orthodox Jews"
replace rgother = 1 if `varname' == "Progressive Jews"
replace rgother = 1 if `varname' == "Sabian Mandaeans"
replace rgother = 1 if `varname' == "Salafi jihadi claimants"
replace rgother = 1 if `varname' == "Salafists"
replace rgother = 1 if `varname' == "Sikhs"
replace rgother = 1 if `varname' == "Tablighi Jamaat"
replace rgother = 1 if `varname' == "Trinitarian Christians"
}

gen rgmuslim = 0
replace rgmuslim = 1 if rgahmadis == 1
replace rgmuslim = 1 if rgalawites == 1
replace rgmuslim = 1 if rgshias == 1
replace rgmuslim = 1 if rgsufis == 1
replace rgmuslim = 1 if rgsunnis == 1
label variable rgmuslim "Muslims identified as enemy"
label define rgmuslim 0 "No" 1 "Yes"
label values rgmuslim rgmuslim
tab rgmuslim, m

gen rgcja = 0
replace rgcja = 1 if rgatheists == 1
replace rgcja = 1 if rgchristians == 1
replace rgcja = 1 if rgorthodox == 1
replace rgcja = 1 if rgjews == 1
replace rgcja = 1 if rgprotestants == 1
replace rgcja = 1 if rgcatholics == 1
label variable rgcja "Christians/Jews/Atheists identified as enemy"
label define rgcja 0 "No" 1 "Yes"
label values rgcja rgcja
tab rgcja, m

drop religions1 religions2 religions3 religions4 religions5
drop religions6 religions7 religions8 religions9 religions10
drop religions11 religions12 religions13 religions14 religions15

*11. Delete excess variables

drop author date title publication issue
drop pages firstpage lastpage totalpages justificationforinclusion
drop wave timestamp coder militantorganizations ideologies
drop individuals additionalterms apocalypse apocalypticterminology aggression
drop destruction violence prisons worlddomination conquest
drop sharia democracy islamiclaw immorality sexualimmorality
drop intoxicants otherimmorality time terminology comments
drop countries religions

save "X:\Dissertation\FPV Data CAO 2020xxxx.dta"
